package com.mtgdeckbuilder.server.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;

import org.apache.commons.lang.StringUtils;

import com.google.appengine.api.datastore.Key;

/**
 * The object that represents a card.
 * 
 * @author Nicolas Deslandes
 */
@SuppressWarnings("serial")
@Entity
public class Card implements Serializable {

   @Id
   private Key key;

   private Long multiverseId;

   private String name;

   // private String nameForSearch;

   private String type;

   private String edition;

   private List<String> otherEditions;

   private String cost;

   private String text;

   private String artist;

   /**
    * The empty constructor. Initialisation of the arrays.
    */
   public Card() {
      otherEditions = new ArrayList<String>();
   }

   /**
    * @return the key.
    */
   public Key getKey() {
      return key;
   }

   /**
    * @param key the key to set.
    */
   public void setKey(final Key key) {
      this.key = key;
   }

   /**
    * @return the multiverseId.
    */
   public Long getMultiverseId() {
      return multiverseId;
   }

   /**
    * @param multiverseId the multiverseId to set.
    */
   public void setMultiverseId(final Long multiverseId) {
      this.multiverseId = multiverseId;
   }

   /**
    * @return the name.
    */
   public String getName() {
      return name;
   }

   /**
    * @param name the name to set.
    */
   public void setName(final String name) {
      this.name = name;
   }

   /**
    * @return the type.
    */
   public String getType() {
      return type;
   }

   /**
    * @param type the type to set.
    */
   public void setType(final String type) {
      this.type = type;
   }

   /**
    * @return the edition.
    */
   public String getEdition() {
      return edition;
   }

   /**
    * @param edition the edition to set.
    */
   public void setEdition(final String edition) {
      this.edition = edition;
   }

   /**
    * @return the cost.
    */
   public String getCost() {
      return cost;
   }

   /**
    * @param cost the cost to set.
    */
   public void setCost(final String cost) {
      this.cost = cost;
   }

   /**
    * @return the text.
    */
   public String getText() {
      return text;
   }

   /**
    * @param text the text to set.
    */
   public void setText(final String text) {
      this.text = text;
   }

   /**
    * @return the artist.
    */
   public String getArtist() {
      return artist;
   }

   /**
    * @param artist the artist to set.
    */
   public void setArtist(final String artist) {
      this.artist = artist;
   }

   /**
    * @param nameInUpperCase the nameInUpperCase to set.
    * @deprecated this setter is mandatory by the jpa/jdo framework must be not be used.
    */
   @Deprecated
   public void setNameInUpperCase(final String nameInUpperCase) {
   }

   /**
    * @return the nameInUpperCase.
    */
   @Basic
   public String getNameInUpperCase() {
      if (StringUtils.isEmpty(name)) {
         return null;
      }
      return name.toUpperCase();
   }

   /**
    * @return the otherEditions.
    */
   public List<String> getOtherEditions() {
      return otherEditions;
   }

   /**
    * @param otherEditions the otherEditions to set.
    */
   public void setOtherEditions(final List<String> otherEditions) {
      this.otherEditions = otherEditions;
   }

}
